<template>
  <div class="vx-title-bar">
    <div class="step-wrap">
      <div class="step-item" v-for="(item, index) in list" :key="index">
        <div v-if="index + 1 < current" class="step-icon-1">
          <img src="@/assets/image/common/arrow-reached.png" alt="步骤箭头" />
        </div>
        <div v-if="index + 1 === Number(current) || index + 1 > current" :class="['step-circle', index + 1 == current ? 'active' : 'current']">
          {{ index + 1 }}
        </div>
        <p :class="[index + 1 === Number(current) ? 'active-p' : 'current']">{{ item }}</p>
        <div v-if="list.length !== index + 1" class="step-icon">
          <img v-if="index + 1 < current" src="@/assets/image/common/arrow-step-active.png" alt="步骤箭头" />
          <img v-else src="@/assets/image/common/arrow-step.png" alt="步骤箭头" />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'vx-title-bar',
  props: {
    list: {
      type: Array,
      default: () => {
        return ['录入信息', '确认信息', '提交结果'];
      },
    },
    current: {
      type: [String, Number],
      default: '1',
    },
  },
};
</script>
<style lang="scss">
.vx-title-bar {
  width: 100%;
  box-sizing: border-box;
  padding: 15px 0;
  background-color: rgba(237, 242, 255, 1);
  margin-bottom: 30px;
  .step-wrap {
    text-align: center;
    vertical-align: top;
    .step-item {
      display: inline-block;
      * {
        display: inline-block;
        vertical-align: top;
      }
      .step-icon-1 {
        width: 24px;
        height: 24px;
        margin: 3px 15px 0 0;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }

    .step-circle {
      width: 22px;
      height: 22px;
      margin: 2px 15px 0 0;
      line-height: 22px;
      text-align: center;
      font-size: $s16;
      border-radius: 50%;
      &.current {
        color: #a1b0d3;
        border: 1.5px solid #a1b0d3;
      }
      &.active {
        color: #fff;
        border: 1.5px solid rgba(65, 114, 238, 1);
        background: rgba(65, 114, 238, 1);
      }
    }

    p {
      line-height: 30px;
      font-size: $s14;
      text-align: left;
      color: #999999;
      &.active-p {
        color: rgba(65, 114, 238, 1);
      }
      &.current {
        color: rgba(161, 176, 211, 1);
      }
    }
    .step-icon {
      width: 72px;
      height: 18px;
      font-size: 26px;
      color: #c0c4cc;
      border: 0;
      flex: 1;
      text-align: center;
      margin: 5px 50px 0 50px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
